﻿using msBsc.AppLogic.DataAlc;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.wMall.Public
{
    public partial class wfMessageRecord : msBsc.Cls.BPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        private void GetMsgRecodr()
        {
            string receiverId = msBsc.SvRef.UserInfo.Operator;
            if (string.IsNullOrEmpty(receiverId))
            {
                this.ExecJScript("layer.msg('已从服务器断开连接，请先登录',3, { shift: 6 });");
                return;
            }
            string senderid = this.GetParamHtValue("senderId");
            if (string.IsNullOrEmpty(senderid))
            {
                this.ExecJScript("layer.msg('请选择要查看的对象',3, { shift: 6 });");
                return;
            }
            string pageIndex = this.GetParamHtValue("pageIndex");
            int index = 1;
            if (!string.IsNullOrEmpty(pageIndex))
            {
                int.TryParse(pageIndex, out index);
            }

            using (CBizChatMessage chatMessage = new CBizChatMessage())
            {
                DataTable dt = chatMessage.GetMessageRecord(senderid, receiverId, "0", index, 15);
                DataTable dtCopy = dt.Copy();
                DataView dv = dt.DefaultView;
                dv.Sort = "MESSAGE_SEND_TIME";
                dtCopy = dv.ToTable();

                string message = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(dtCopy, "", "", 1, 15, "");
                this.ExecJScript("GetRecordMessage("+message+","+pageIndex+")");
            }
        }

        public override void DoAction()
        {
            if (this.strAction == "msgRecodr")
            {
                GetMsgRecodr();
            }
        }
    }
}